﻿using Microsoft.AspNetCore.Mvc;
using Sgr.AspNetCore.ActionFilters.AuditLogs;
using Sgr.AspNetCore.ActionFilters.Permissions;
using Sgr.AuditLogs.Model;
using Sgr.AuditLogs.Services;

namespace Sgr.AuditLogs.Controllers
{
    /// <summary>
    /// 审计日志统计接口
    /// </summary>
    [Route("api/v1/sgr/audit-overview")]
    [ApiController]
    [Produces("application/json")]
    [Tags("LogOverview")]
    public class LogOverviewController : ControllerBase
    {
        private readonly IAuditSummaryService _auditOverviewService;
        private readonly ICurrentUser _currentUser;

        public LogOverviewController(IAuditSummaryService auditOverviewService, ICurrentUser currentUser)
        {
            _auditOverviewService = auditOverviewService;
            _currentUser = currentUser;
        }

        /// <summary>
        /// 获取当前用户所属组织的每周审计日志汇总信息
        /// </summary>
        ///// <param name="cancellationToken">取消令牌</param>
        [CheckPermission(Permissions.QueryAuditLogPermission)]
        [HttpPost("overview/current-org")]
        [ProducesResponseType(typeof(AuditOverviewPreWeek), StatusCodes.Status200OK)]
        [AuditLogActionFilter("查询审计日志列表")]
        public Task<ActionResult<AuditOverviewPreWeek>> GetCurrentOrgAuditOverview(/*CancellationToken cancellationToken*/)
        {
            //long orgId = QueryHelper.GetOrgId(_currentUser);

            // 调用服务获取统计结果
            var data = new AuditOverviewPreWeek();
            return Task.FromResult<ActionResult<AuditOverviewPreWeek>>(Ok(data));
        }
    }
}